<?php
//$this->breadcrumbs=array(
//	$model->username,
//);
?>

<h1><?php echo $model->username; ?></h1>

<?php foreach ($model->service as $service):?>

<h2><?php echo Yii::t('main','Counters'); ?></h2>
<ul>
	<li><?php echo Yii::t('main','In').': '.$service->inC.' '.Yii::t('main','Mb')?></li>
	<li><?php echo Yii::t('main','Out').': '.$service->outC.' '.Yii::t('main','Mb')?></li>
	<li><?php echo Yii::t('main','Total').': '.'<b>'.$service->totalC.' '.Yii::t('main','Mb').'</b>'?></li>
</ul>

<h2><?php echo Yii::t('main','Finance Information'); ?></h2>
<ul>
<li><?php echo Yii::t('main','Balance').':'?></li>
<li><?php echo Yii::t('main','Blocked')?></li>
</ul>

<?php endforeach; ?>

<br />
<h2><?php echo Yii::t('main','Information Of User'); ?></h2>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'contract',
		'username',
		'address',
		'email',
		'telephon',
),
)); ?>

<br />
<h2><?php echo Yii::t('main','Services'); ?></h2>

<?php $this->widget('MyGridView', array(
	'id'=>'service-grid',
	'dataProvider'=>$serviceModel->search(),
	'filter'=>$serviceModel,
	'columns'=>array(
		array(
			'name'=>'type',
			'value'=>'Lookup::item("ServiceType",$data->type)',
			'filter'=>Lookup::items('ServiceType'),
		),
		'ip',
		'cost',
		'cost_this_month',
		array(
			'name'=>'packet_id',
			'value'=>'$data->packet->name',
			//'filter'=>$serviceModel->packet->findAll,
		),
		array(
			'name'=>'speed_id',
			'value'=>'$data->speed->name',
		),
		'comment',
		'start_date',
		'end_date',
		'is_blocked',
		'pay_date',
		'last_pay_date',
	),
)); ?>

<br />
<h2><?php echo Yii::t('main','Payments'); ?></h2>

<?php $this->widget('MyGridView', array(
	'id'=>'payment-grid',
	'dataProvider'=>$paymentModel->search(),
	'filter'=>$paymentModel,
	'columns'=>array(
		'payment_date',
		array(
			'name'=>'payment_sum',
			'htmlOptions'=>array('class'=>'sum','id'=>'payment'),
			'footer'=>$paymentModel->getTotals()->payment_sum, 			//'footer'=>$provider->itemCount===0 ? '' : $model->getTotals(),
			'footerHtmlOptions'=>array('class'=>'total','id'=>'payment'),
		),
		'faktura_number',
		array(
			'name'=>'is_prepayment',
			'value'=>'$data->is_prepayment?$data->prepayment_date:""',
			'filter'=>Lookup::items('Boolean'),
			'htmlOptions'=>array('class'=>'red'),
		),
		array(
			'name'=>'admin_id',
			'value'=>'$data->admin->username',
		),
		'comment',
	),
)); ?>

<div id="history">
<?php echo CHtml::ajaxLink(Yii::t('Payment','History (click to show)'),$this->createUrl('history',array('id'=>$model->id,'ajax'=>'history-grid')),
		array('update'=>'#history','beforeSend'=>'js:function(){jQuery(this).addClass("loading");}'),	//FIXME добавление картинки загрузки
		array('id'=>'showHistory','href'=>$this->createUrl('history',array('id_id'=>$model->id)))
);?>
</div>
